package ar.uba.fi.RSACryptoFiuba.model;

import org.apache.commons.lang3.StringUtils;


public abstract class RSAStep {
	
	private RSAStep previous;
	private RSAStep next;
	
	public RSAStep(){
		this.previous = null;
		this.next = null;
	}
		
	public abstract void execute(RSAMessage message);
	
	public abstract void undo(RSAMessage message);
	
	public abstract void test(RSAMessage message);

	public RSAStep getPrevious() {
		return previous;
	}

	public void setPrevious(RSAStep previous) {
		this.previous = previous;
	}

	public RSAStep getNext() {
		return next;
	}
	
	public boolean isFirst(){
		return this.previous == null;
	}
	
	public boolean isLast(){
		return this.next == null;
	}

	public void setNext(RSAStep next) {
		this.next = next;
	}
	
	public void verifyNumericalValue(String element) {
		if(!StringUtils.isNumeric(element)){
			throw new InvalidValueException("El valor ingresado debe ser numérico.");			
		}
	}
}
